package com.common.demo.mapper;

import com.common.demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.Mapping;

import java.util.List;

/**
 * @Description UserMapper
 * @Author xiao  xun
 * @Date 2025-09-10
 */
@Mapper
public interface UserMapper {
    @Select("select * from user where username = #{username}")
    User selectByUsername(String username);
@Select("select r.path paths from\n" +
        "    user u #通过用户名找到角色\n" +
        "        inner join user_role ur on u.id = ur.user_id #关联表找到该用户拥有的角色ID\n" +
        "        inner join role on ur.role_id = role.id #角色表找到角色详细信息\n" +
        "        inner join role_resource rr on ur.role_id = rr.role_id #角色资源表找到角色所拥有的资源ID\n" +
        "        inner join resource r on rr.resource_id = r.id #资源表找到资源详细信息\n" +
        "where u.username = #{username} and r.status = 1 and r.resource_type = 3;")
List<String>  selectrole(String username);
}
